import { message } from 'ant-design-vue';
import type {DtoCtrlPlan} from "./type.ts";


// 添加
export const addCtrlPlan = (ctrlPlans: DtoCtrlPlan[]) => {
    const lastCtrlPlan = ctrlPlans[ctrlPlans.length - 1];
    if (lastCtrlPlan && lastCtrlPlan.cpSpec?.trim() !== '') {
        ctrlPlans.push({
            cpId:undefined,
            cpSpec:undefined,
            capacityId:undefined,
            capacityCn:undefined,
            frequencyList:[],
            reactionPlanList:[],
        });
    } else {
        message.warning('请先填写当前控制规格/要求描述');
    }
};

// 移除
export const removeCtrlPlan = (ctrlPlans: DtoCtrlPlan[], index: number) => {
    if (ctrlPlans.length > 1) {
        ctrlPlans.splice(index, 1);
    } else {
        message.warning('至少需要保留一个控制规格/要求');
    }
};
